#include<stdio.h>
/*
buffer=abc

buffer=abc

abcd
buffer=abcd
buffer=abcd

 *
 */

int main(){
	FILE * fp = fopen("1.txt", "r");
	if(fp == NULL){
		perror("fopen");
		return 0;
	}
	char * ret;
	char buffer[100];

	//1. 从文件中读取行字符
	ret = fgets(buffer, 5, fp);
	if(ret == NULL){
		perror("fgets");
		fclose(fp);
		return 0;
	}
	printf("buffer=%s\n", buffer);
	printf("buffer=%s\n", ret);

	//2.从键盘文件中读取行字符
	ret = fgets(buffer, 5, stdin);
	if(ret == NULL){
		perror("fgets");
		fclose(fp);
		return 0;
	}
	printf("buffer=%s\n", buffer);
	printf("buffer=%s\n", ret);
	
}
